package com.wwx.controller;

import com.wwx.entity.UserEntity;
import com.wwx.validator.group.AddGroup;
import com.wwx.validator.group.DefaultGroup;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * TestController
 *
 * @author 王伟鑫
 * @version 0.1v
 * @create 2023-02-11 10:33
 **/
@Validated
@RestController
@RequestMapping("/test")
public class TestController {


//	@PostMapping("save")
//	public Object save(@Valid @RequestBody UserEntity user, BindingResult bindingResult){
//		if(bindingResult.hasErrors()){
//			return bindingResult.getAllErrors();
//		}
//		System.out.println(user);
//		return "OK";
//	}
	@PostMapping("save")
	public Object save(@Validated({DefaultGroup.class}) @RequestBody UserEntity user){
//		ValidatorUtils.validateEntity(user, DefaultGroup.class, AddGroup.class);
		System.out.println(user);
		return "OK";
	}
	@PostMapping("save1")
	public Object save1(@Validated({AddGroup.class}) @RequestBody UserEntity user){
//		ValidatorUtils.validateEntity(user, DefaultGroup.class, AddGroup.class);
		System.out.println(user);
		return "OK";
	}
}